#include <iostream>
#include <cmath>
using namespace std;

int n, count;
void solve() {
	cin >> n;
	count = 0;
	for (int i=1;i<n;++i) {
		for (int j=i;j<n;++j) {
			int temp = i*i + j*j;
			if (temp > n*n) {
				break;
			}
			else {
				int half = sqrt(temp);
				if (half * half == temp || (half+1)*(half+1) == temp) {
					count++;
				}
			}
		}
	}
	cout << count << "\n";
}

int main() {
	solve();
	return 0;
}
